package com.yl.ydk.ui.fragment.home

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.yl.ydk.R
import com.yl.ydk.base.BaseFragment
import com.yl.ydk.ui.activity.*
import kotlinx.android.synthetic.main.fragment_healthy.*

class HealthyFragment : BaseFragment(), View.OnClickListener {

    companion object {
        fun getInstance(): HealthyFragment {
            return HealthyFragment()
        }
    }

    override fun getLayoutResId(): Int = R.layout.fragment_healthy

    override fun attachView() {

    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        cvHealthyKnow.setOnClickListener(this)
        cvHealthyMall.setOnClickListener(this)
        cvHealthtestCategory.setOnClickListener(this)
        cvLiveList.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.cvHealthyKnow -> {
                HomeActivity.homeActivity?.let {
                    it.startActivityIn(Intent(it, HealthyKnowActivity::class.java), it)
                }
            }
            R.id.cvHealthyMall -> {
                HomeActivity.homeActivity?.let {
                    it.startActivityIn(Intent(it, HealthyMallHomeActivity::class.java), it)
                }
            }
            R.id.cvHealthtestCategory -> {
                HomeActivity.homeActivity?.let {
                    it.startActivityIn(Intent(it, HealthtestCategoryActivity::class.java), it)
                }
            }
            R.id.cvLiveList -> {
                HomeActivity.homeActivity?.let {
                    it.startActivityIn(Intent(it, LiveListActivity::class.java), it)
                }
            }
        }
    }

}